package ru.amse.tsyganov.jumleditor.graphicaleditor.collaboration;

import ru.amse.tsyganov.jumleditor.graphicaleditor.GraphicalEditor;
import ru.amse.tsyganov.jumleditor.graphicaleditor.common.AddEdgeMode;
import ru.amse.tsyganov.jumleditor.model.collaboration.Message;
import ru.amse.tsyganov.jumleditor.model.common.Edge;
import ru.amse.tsyganov.jumleditor.model.common.GraphModel;
import ru.amse.tsyganov.jumleditor.model.common.StateVertex;
import ru.amse.tsyganov.jumleditor.view.ConnectionPoint;
import ru.amse.tsyganov.jumleditor.view.collaboration.MessageView;
import ru.amse.tsyganov.jumleditor.view.common.EdgeView;
import ru.amse.tsyganov.jumleditor.view.common.GraphView;

public class AddMessageMode extends AddEdgeMode {

	public AddMessageMode(GraphicalEditor graphicalEditor) {
		super(graphicalEditor);
	}

	@Override
	public EdgeView<? extends Edge> createEdgeView(
			StateVertex sourceStateVertex, StateVertex targetStateVertex,
			ConnectionPoint sourceConnectionPoint,
			ConnectionPoint targetConnectionPoint,
			GraphView<? extends GraphModel> graph) {
		
		Message message = new Message(
				sourceStateVertex, 
				targetStateVertex);
		
		EdgeView<? extends Edge> messageView = 
			new MessageView<Message>(message, 
					graph,
					sourceConnectionPoint,
					targetConnectionPoint);
		
		return messageView;
	}

	@Override
	public boolean isClosureAllowed() {
		return true;
	}

	@Override
	public boolean isDublicateAllowed() {
		return true;
	}

}
